﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TransportHierarchyWithForms
{
    public abstract class Transport
    {
        public Route[] routes;
        protected uint capacity;
        protected uint numberOfRouts = 0;
        protected string company;
        protected string nameOfTransport;

        public uint NumberOfRouts
        {
            get
            {
                return numberOfRouts;
            }
            set
            {
                numberOfRouts = value;
            }
        }

        public uint Capacity
        {
            get
            {
                return capacity;
            }
            set
            {   
                capacity = value;
            }
        }
        public Transport(uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport){
            this.capacity=capacity;
        }

        public Transport()
        {
            capacity=0;
            numberOfRouts = 0;
            company="";
            nameOfTransport="";
        }

        public string Company
        {
            get
            {
                return company;
            }
            set
            {
                company = value;
            }
        }

        public string NameOfTransport
        {
            get
            {
                return nameOfTransport;
            }
            set
            {
                nameOfTransport = value;
            }
        }

        public override string ToString()
        {
            string SumString = string.Format("Model: {0}; Company: {1}; Capacity: {2}", nameOfTransport, Company, capacity.ToString());
            for (uint i = 0; i < numberOfRouts; i++)
            {
                SumString += '\n'+(i + 1).ToString() + " Route: " +
                "Начальная точка: " + routes[i].Begin +
                " Конечная точка: " + routes[i].Begin + " Длина пути: " +
////////////////////////////ОШИБКА///////////////////////////////////////////
                routes[i].Length.ToString() + " Стоимость: " +
                routes[i].Length.ToString();
///////////////////////////////////////////////////////////////////////
            }
            return SumString;
        }

    }
    /// <summary>
    /// Avia
    /// </summary>
    public abstract class AviaTransport:Transport
    {
        protected double speed;
        
        public double Speed {
            get
            {
                return speed;
            }
            set
            {
                speed = value;
            }
        }

        public AviaTransport(double speed, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport):base(NumberOfRouts,capacity,nameOfCompany, nameOfTransport){
            this.speed = speed;
        }

        public AviaTransport()
        {
            nameOfTransport = "";
            capacity = 0;
            Company = "";
        }
    }

    public class Airplane : AviaTransport
    {
        protected bool isSeaPlane;

        public bool IsSeaPlane
        {
            get
            {
                return isSeaPlane;
            }
            set
            {
                isSeaPlane = value;
            }
        }

        public Airplane(double speed, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport, bool isSeaPlane)
            : base(speed, NumberOfRouts, capacity, nameOfCompany, nameOfTransport)
        {
            this.isSeaPlane = isSeaPlane;
        }
        public Airplane()
            : base()
        {

        }
    }

    public class Helicopter : AviaTransport
    {
        protected uint numberOfEngines;

        public uint NumberOfEngine
        {
            get
            {
                return numberOfEngines;
            }
            set
            {
                numberOfEngines = value;
            }
        }

        public Helicopter(double speed, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport, uint numberOfEngines)
            : base(speed, NumberOfRouts, capacity, nameOfCompany, nameOfTransport)
        {
            this.numberOfEngines = numberOfEngines;
        }
        public Helicopter()
            : base()
        {
            NumberOfEngine = 0;
        }
    }


    /// <summary>
    /// Surface
    /// </summary>
    public abstract class SurfaceTransport : Transport
    {
        protected double weight;

        public double Weight
        {
            get
            {
                return weight;
            }
            set
            {
                if (value > 0)
                {
                    weight = value;
                }
            }
        }

        public SurfaceTransport(double weight, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport):base(NumberOfRouts,capacity,nameOfCompany, nameOfTransport){
            this.weight = weight;
        }
        public SurfaceTransport()
            : base()
        {
            weight = 0;
        }

    }

    public class Train : SurfaceTransport
    {
        protected uint numberOfWagons;

        public uint NumberOfWagons
        {
            get
            {
                return numberOfWagons;
            }
            set
            {
                numberOfWagons = value;
            }
        }

        public Train(double weight, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport, uint numberOfWagons):base(weight, NumberOfRouts, capacity, nameOfCompany, nameOfTransport){
            this.numberOfWagons = numberOfWagons;
        }
        public Train()
            : base()
        {
            numberOfWagons = 0;
        }
    }

    public class Bus : SurfaceTransport
    {
        protected uint numberOfDoors;

        public uint NumberOfDoors
        {
            get
            {
                return numberOfDoors;
            }
            set
            {
                numberOfDoors = value;
            }
        }

        public Bus(double weight, uint NumberOfRouts, uint capacity, string nameOfCompany, string nameOfTransport, uint numberOfDoors):base(weight, NumberOfRouts, capacity, nameOfCompany, nameOfTransport){
            this.numberOfDoors = numberOfDoors;
        }
        public Bus():base()
        {
            numberOfDoors = 0;
        }
    }
}
